package com.hqd.ch03.v49.context.annotation;

import com.hqd.ch03.v49.beans.factory.parsing.Location;
import com.hqd.ch03.v49.core.type.MethodMetadata;

/**
 * 配置类方法
 */
abstract class ConfigurationMethod {

    /**
     * 方法元信息
     */
    protected final MethodMetadata metadata;

    /**
     * 配置类
     */
    protected final ConfigurationClass configurationClass;


    public ConfigurationMethod(MethodMetadata metadata, ConfigurationClass configurationClass) {
        this.metadata = metadata;
        this.configurationClass = configurationClass;
    }

    public MethodMetadata getMetadata() {
        return this.metadata;
    }

    public ConfigurationClass getConfigurationClass() {
        return this.configurationClass;
    }

    public Location getResourceLocation() {
        return new Location(this.configurationClass.getResource(), this.metadata);
    }


    @Override
    public String toString() {
        return String.format("[%s:name=%s,declaringClass=%s]",
                getClass().getSimpleName(), getMetadata().getMethodName(), getMetadata().getDeclaringClassName());
    }

}
